package com.laihuichuxing.demo;

import java.util.concurrent.CyclicBarrier;

/**
 * @author YangGuang
 * @program: learn-thread
 * @description:
 * @create: 2018-12-25 14:16
 **/
public class CyclicBarrierTest2 {
    static CyclicBarrier c = new CyclicBarrier(2, new A());

    public static void main(String[] args) {
        new Thread(() -> {
                try {
                    c.await();
                } catch (Exception e) {
                }
                System.out.println(1);
            }).start();
            try {
            c.await();
            } catch (Exception e) {
            }
            System.out.println(2);

    }

    static class A implements Runnable {
        @Override
        public void run() {
            System.out.println(3);
        }
    }
}
